package cn.wen.eeayjoke.ui;


import android.view.View;
import android.widget.Toast;

import cn.wen.core.titlebar.DefTitleBar;
import cn.wen.core.ui.AppActivity;
import cn.wen.eeayjoke.R;
import cn.wen.eeayjoke.entity.bean.login.LoginBean;
import cn.wen.eeayjoke.entity.data.LoginData;
import cn.wen.eeayjoke.net.observer.DialogObserver;
import cn.wen.eeayjoke.net.presenter.LoginPresenter;

/**
 * 网络接口测试
 */
public class NetTestActivity extends AppActivity {
    private LoginPresenter presenter = new LoginPresenter();

    @Override
    public Object getContentLayout() {
        return R.layout.activity_net_test;
    }

    /**
     * 调用登录接口
     */
    public void open(View view) {
        LoginData loginData = new LoginData("13556285219", "123456");
        presenter.login(loginData, new DialogObserver<LoginBean>(getAppActivity()) {
            @Override
            public void onNext(LoginBean data) {
                // TODO 做登录的成功的操作
                Toast.makeText(getAppActivity(), "" + data.userInfo.nickName, Toast.LENGTH_SHORT).show();
            }
        });
    }


    @Override
    protected void initTitle(DefTitleBar titleBar) {
        titleBar.setTitle("网络接口测试");
    }

}
